package com.hdjk.view.callback;

import com.lst.projectlib.entity.Msg;

import org.json.JSONArray;
import org.json.JSONObject;

import okhttp3.Response;

/**
 * Created by Admin on 2017/10/25.
 */

public abstract class TakeWalletCallback extends MsgCallBack {
    @Override
    public Msg parseNetworkResponse(Response response, int id)
            throws Exception {

        Msg msg = super.parseNetworkResponse(response, id);
        JSONObject object = (JSONObject) msg.getData();
        if (object != null && !object.isNull("data")) {
            JSONArray array = object.getJSONArray("data");
            if (array != null) {
                String status = "";
                for (int j = 0; j < array.length(); j++) {
                    JSONObject jsonObject = array.getJSONObject(j);
                    if (!jsonObject.isNull("transactionStatus")) {
                        status = jsonObject.getString("transactionStatus");
                    }
                }
                msg.setData(status);
            }
        }
        return msg;
    }
}